﻿//--------------------------------------------------------------------------
// 
//  Copyright (c) Chili Software.  All rights reserved. 
// 
//  File: OEMember.cs
//
//  Description: Member for the ObjectExpression.
// 
//--------------------------------------------------------------------------

using System;

namespace Chili.Opf3.Query.OPathParser
{
	/// <summary>
	/// Represents a object member in the OPath statement. 
	/// </summary>
	/// <remarks>
	/// Object members in a OPath statement are converted to this class when OPath is compiled. The class
	/// contains the name of the object member specified in the OPath statement, the 
	/// <see cref="Opf3.FieldAttribute">FieldAttribute</see> of the object member and the 
	/// <see cref="Opf3.PersistentAttribute">PersistentAttribute</see> of the persistent object.
	/// </remarks>
	[Serializable]
	public sealed class OEMember : OEItem
	{
		private FieldAttribute _fieldAttribute;
		private PersistentAttribute _persistentAttribute;
		private string _memberName;

		/// <summary>
		/// Creates a new instance of the <see cref="OEMember">OEMember Class</see>.
		/// </summary>
		/// <param name="memberName">Name of the object member in the OPath statement.</param>
		/// <param name="fieldAttribute"><see cref="Opf3.FieldAttribute">FieldAttribute</see> set on the property.</param>
		/// <param name="persistentAttribute"><see cref="Opf3.PersistentAttribute">PersistentAttribute</see>
		/// of the persistent object.</param>
		internal OEMember(string memberName, FieldAttribute fieldAttribute, PersistentAttribute persistentAttribute)
		{
			_fieldAttribute = fieldAttribute;
			_persistentAttribute = persistentAttribute;
			_memberName = memberName;
		}

		/// <summary>
		/// Returns the name of the object member in the OPath statement.
		/// </summary>
		/// <value>Name of the property in the OPath statement.</value>
		public string MemberName
		{
			get { return _memberName; }
		}

		/// <summary>
		/// Returns the <see cref="Opf3.FieldAttribute">FieldAttribute</see> set on the property.
		/// </summary>
		/// <value>The <see cref="Opf3.FieldAttribute">FieldAttribute</see> set on the property.</value>
		public FieldAttribute FieldAttribute
		{
			get { return _fieldAttribute; }
		}

		/// <summary>
		/// Returns the <see cref="Opf3.PersistentAttribute">PersistentAttribute</see> of the persistent object.
		/// </summary>
		/// <value>The <see cref="Opf3.PersistentAttribute">PersistentAttribute</see> of the persistent object.</value>
		public PersistentAttribute PersistentAttribute
		{
			get { return _persistentAttribute; }
		}
	}
}
